package com.hex.ds.hdrs.period.task.converter;

import com.hex.ds.hdrs.common.constant.TaskStatusCode;
import com.hex.ds.hdrs.period.task.dto.depend.DependPeriodTaskDto;
import com.hex.ds.hdrs.period.task.po.PeriodTask;
import com.hex.ds.hdrs.period.task.po.PeriodTaskDef;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(componentModel = "spring", imports = {TaskStatusCode.class})
public interface IDependPeriodTaskDtoConverter {

    @Mapping(target = "taskStatus", constant = "未生成实例")
    @Mapping(target = "taskType", constant = "periodTaskDef")
    DependPeriodTaskDto toNodeInfoByDef(PeriodTaskDef periodTaskDef);

    @Mapping(target = "taskStatus", expression = "java(TaskStatusCode.getStatus(periodTask.getTaskStatus()))")
    @Mapping(target = "taskType", constant = "periodTask")
    DependPeriodTaskDto toNodeInfo(PeriodTask periodTask);

}
